package com.zuqiuzhandui.liveing.view.choose;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.ViewTarget;
import com.zuqiuzhandui.R;
import com.zuqiuzhandui.liveing.model.resultModel.TeamListRs;
import com.zuqiuzhandui.liveing.util.ImageUrlUtil;
import com.zuqiuzhandui.testing.myhelper.net.GlideCircleTransform;

import butterknife.ButterKnife;

/**
 * Created by yq on 2016-10-13.
 */

public class TeamItem {
    public static void setItem(final Context context, TeamListRs data, View view){
     final  TextView tvTeam= ButterKnife.findById(view, R.id.tv_team);
        tvTeam.setText(data.getName());
        ViewTarget<TextView, GlideDrawable> viewTarget = new ViewTarget<TextView, GlideDrawable>(tvTeam) {

            @Override
            public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                resource.setBounds(0,0,resource.getIntrinsicWidth(),resource.getIntrinsicHeight());
                Drawable drawable = ContextCompat.getDrawable(context, R.mipmap.right_arrows);
                drawable.setBounds(0,0,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());
                tvTeam.setCompoundDrawables(resource, null, drawable, null);
            }
        };
        Glide.with(context)
                .load(ImageUrlUtil.processUrl(26,26,data.getLogo()))
                .transform(new GlideCircleTransform(context))
                .into(viewTarget);

    }
}
